home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / internal / m68k / m68k-emul / dispatch.s < prev    next >
Encoding:
Text File  |  1996-07-16  |  1.6 KB  |  83 lines

  1.     Exception   =    -0x30
  2.     Disable     =    -0x78
  3.     Enable        =    -0x7e
  4.     ThisTask    =    0x114
  5.     IDNestCnt   =    0x126
  6.     TaskReady   =    0x196
  7.     tc_Flags    =    0xe
  8.     tc_State    =    0xf
  9.     tc_IDNestCnt=    0x10
  10.     tc_SPReg    =    0x36
  11.     tc_Switch   =    0x42
  12.     tc_Launch   =    0x46
  13.     TS_RUN        =    2
  14.     TB_EXCEPT   =    5
  15.     TB_SWITCH   =    6
  16.     TB_LAUNCH   =    7
  17.  
  18.     | Dispatching routine for the 68000.
  19.     | Higher models (with FPU) need a slightly different
  20.     | routine or the additional registers cannot be used!
  21.  
  22.     .globl    _Exec_Dispatch
  23. _Exec_Dispatch:
  24.  
  25.     | move whole user context to user stack
  26.     moveml    d0-d7/a0-a6,sp@-
  27.  
  28.     | get current task and store sp there
  29.     movel    a6@(ThisTask),a2
  30.     movel    sp,a2@(tc_SPReg)
  31.  
  32.     | call the switch routine if necessary
  33.     btst    #TB_SWITCH,a2@(tc_Flags)
  34.     jeq    noswch
  35.     movel    a2@(tc_Switch),a5
  36.     jsr    a5@
  37.  
  38.     | store IDNestCnt
  39. noswch: moveb    a6@(IDNestCnt),a2@(tc_IDNestCnt)
  40.     moveb    #-1,a6@(IDNestCnt)
  41.  
  42.     | get address of ready list
  43.     leal    a6@(TaskReady),a0
  44.  
  45.     | there must be a ready task
  46.     movel    a0@,a2
  47.     movel    a2@,a1
  48.  
  49.     | remove first ready task in the list
  50.     movel    a1,a0@
  51.     movel    a0,a1@(4:W)
  52.  
  53.     | and use it as new current task
  54.     movel    a2,a6@(ThisTask)
  55.     moveb    #TS_RUN,d0
  56.     moveb    d0,a2@(tc_State)
  57.  
  58.     | restore IDNestCnt
  59.     moveb    a2@(tc_IDNestCnt),a6@(IDNestCnt)
  60.  
  61.     | call the launch routine if necessary
  62.     btst    #TB_LAUNCH,a2@(tc_Flags)
  63.     jeq    nolnch
  64.     movel    a2@(tc_Launch),a5
  65.     jsr    a5@
  66.  
  67.     | get stack pointer
  68. nolnch: movel    a2@(tc_SPReg),sp
  69.  
  70.     | test task exception bit
  71.     btst    #TB_EXCEPT,a2@(tc_Flags)
  72.     jeq    noexc
  73.  
  74.     | Raise a task exception in Disable()d state.
  75.     jsr    a6@(Disable)
  76.     jsr    a6@(Exception)
  77.     jsr    a6@(Enable)
  78.  
  79.     | restore context
  80. noexc:    moveml    sp@+,d0-d7/a0-a6
  81.     rts
  82.  
  83.